package com.example.xd.tuiliu_test.videoplayer.render;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;

import com.example.xd.tuiliu_test.videoplayer.render.listener.ISurfaceListener;


public class SurfaceRenderView extends SurfaceView implements IRenderView, SurfaceHolder.Callback {
    ISurfaceListener surfaceListener;

    public SurfaceRenderView(Context context) {
        super(context);
        initView();
    }

    private void initView() {
        getHolder().addCallback(this);
    }

    @Override
    public ISurfaceListener getISurfaceListener() {
        return surfaceListener;
    }

    @Override
    public void setISurfaceListener(ISurfaceListener surfaceListener) {
        this.surfaceListener = surfaceListener;
    }

    @Override
    public int getSizeH() {
        return getHeight();
    }

    @Override
    public int getSizeW() {
        return getWidth();
    }

    @Override
    public View getRenderView() {
        return this;
    }

    @Override
    public Bitmap initCover() {
        return null;
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {

    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
//        if (surfaceListener != null) {
//            surfaceListener.onSurfaceAvailable(this);
//        }
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {

    }
}
